home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 1999 June / June 99, disk1,APC461.iso / workshop / other / litres1.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-04-06  |  1.0 KB  |  38 lines

  1. // **************************************************************
  2. // litres1.cpp
  3. // Example program for Simple C++
  4. //
  5. // (c) 1999 Emmenjay Consulting Pty Ltd                          
  6. //                                                               
  7. // History                                                       
  8. // 06/04/99 MJS  Initial Coding.                                 
  9. //                                                               
  10. // **************************************************************
  11.  
  12. #include <iostream>
  13.  
  14. // THIS IS THE NUMBER OF LITRES IN ONE GALLON
  15. const double L_PER_GAL = 3.785411784;
  16.  
  17. double litres( int gallons )
  18. {
  19.   return gallons * L_PER_GAL;
  20. }
  21.  
  22. // DEFINE THE RANGE OF VALUES OVER WHICH 
  23. // THE COMPUTATION WILL BE PERFORMED
  24. const int FIRST = 1;
  25. const int LAST  = 10;
  26.  
  27. int main()
  28. {
  29.   int i;
  30.  
  31.   std::cout << "Gallons\tLitres\n";
  32.   std::cout << "-------\t------\n";
  33.   for (i=FIRST; i<=LAST; i++)
  34.     std::cout << i << "\t" << litres(i) << '\n';
  35.  
  36.   return 0;
  37. }
  38.